# 测试订单更新接口
# 网关地址: http://115.190.179.32:8000/traceapiwrite/api/Order/Update

$body = @'
{
  "id": 5,
  "order_number": "ORD-20250914-004",
  "item_name": "99%纯度异丙醇（工业航天级）",
  "quantity": 8,
  "unit_length": 35,
  "unit_width": 35,
  "unit_height": 45,
  "total_weight": 48,
  "total_volume": 441000,
  "is_fragile": true,
  "temperature_control": "阴凉通风（<25℃，远离火源）",
  "is_hazardous": true,
  "packaging_type": "防爆铁桶（带泄压阀）",
  "notes": "需符合GB 190-2009危险品包装标准，单独配送不可混装55",
  "lastModifiedBy": "王大锤",
  "CreatedBy": "王大锤"
}
'@

Write-Host "正在测试订单更新接口..." -ForegroundColor Cyan
Write-Host "URL: http://115.190.179.32:8000/traceapiwrite/api/Order/Update" -ForegroundColor Yellow
Write-Host ""

try {
    $response = Invoke-RestMethod -Uri "http://115.190.179.32:8000/traceapiwrite/api/Order/Update" `
                                   -Method Post `
                                   -Body $body `
                                   -ContentType "application/json; charset=utf-8"
    
    Write-Host "✅ 请求成功！" -ForegroundColor Green
    Write-Host ""
    Write-Host "响应数据:" -ForegroundColor Green
    $response | ConvertTo-Json -Depth 10
} catch {
    Write-Host "❌ 请求失败！" -ForegroundColor Red
    Write-Host ""
    Write-Host "错误信息:" -ForegroundColor Red
    Write-Host $_.Exception.Message
    Write-Host ""
    if ($_.Exception.Response) {
        Write-Host "HTTP状态码: $($_.Exception.Response.StatusCode.value__)" -ForegroundColor Red
        Write-Host "状态描述: $($_.Exception.Response.StatusDescription)" -ForegroundColor Red
    }
}

